home *** CD-ROM | disk | FTP | other *** search
/ Champak 139 / (Vol 139) Sep 24 2011.iso / Games / seo_game.swf / scripts / PlatformGame.as < prev    next >
Text File  |  2011-09-24  |  32KB  |  1,132 lines

  1. package
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.display.SimpleButton;
  5.    import flash.display.StageScaleMode;
  6.    import flash.events.Event;
  7.    import flash.events.KeyboardEvent;
  8.    import flash.events.MouseEvent;
  9.    import flash.events.TimerEvent;
  10.    import flash.media.SoundChannel;
  11.    import flash.media.SoundTransform;
  12.    import flash.net.URLRequest;
  13.    import flash.net.URLVariables;
  14.    import flash.net.navigateToURL;
  15.    import flash.net.sendToURL;
  16.    import flash.text.TextField;
  17.    import flash.utils.Timer;
  18.    import flash.utils.getTimer;
  19.    
  20.    public class PlatformGame extends MovieClip
  21.    {
  22.       
  23.       static const edgeDistance:Number = 120;
  24.       
  25.       static const gravity:Number = 0.0035;
  26.        
  27.       
  28.       private var enemies:Array;
  29.       
  30.       public var bgMMenu:MovieClip;
  31.       
  32.       public var sndBtn:MovieClip;
  33.       
  34.       public var oText:TextField;
  35.       
  36.       public var ctTxt:TextField;
  37.       
  38.       private var gameSound:String = "soundOn";
  39.       
  40.       private var routers:Array;
  41.       
  42.       public var urlString:String;
  43.       
  44.       public var rcBtn:SimpleButton;
  45.       
  46.       public var ebBtn:SimpleButton;
  47.       
  48.       private var lastTime:Number = 0;
  49.       
  50.       public var mpClp:MovieClip;
  51.       
  52.       public var request:URLRequest;
  53.       
  54.       public var bgCredits:MovieClip;
  55.       
  56.       public var jiBtn:Sponsor2;
  57.       
  58.       public var levelDisplay:TextField;
  59.       
  60.       public var emTxt:TextField;
  61.       
  62.       private var playerLives:int;
  63.       
  64.       private var gameMode:String = "start";
  65.       
  66.       private var gameLevel:int;
  67.       
  68.       public var spBtn:SimpleButton;
  69.       
  70.       public var gamelevel:MovieClip;
  71.       
  72.       public var enBtn:SimpleButton;
  73.       
  74.       public var credClp:MovieClip;
  75.       
  76.       public var instClp:MovieClip;
  77.       
  78.       private var hd:SimpleButton;
  79.       
  80.       private var playerObjects:Array;
  81.       
  82.       public var bgPlay:MovieClip;
  83.       
  84.       private var fixedObjects:Array;
  85.       
  86.       public var timeDisplay:TextField;
  87.       
  88.       public var rpBtn:MovieClip;
  89.       
  90.       public var iBtn:SimpleButton;
  91.       
  92.       public var domE:int;
  93.       
  94.       private var timer:Timer;
  95.       
  96.       public var site:String;
  97.       
  98.       public var domS:int;
  99.       
  100.       public var sndChannel:SoundChannel;
  101.       
  102.       private var city:String = "";
  103.       
  104.       public var lgoBtn:Sponsor1;
  105.       
  106.       private var gameLanguage:String = "English";
  107.       
  108.       public var mzBtn:SimpleButton;
  109.       
  110.       public var domStr:String;
  111.       
  112.       public var bgdSound:TechnoLoop;
  113.       
  114.       private var usbs:Array;
  115.       
  116.       public var variables:URLVariables;
  117.       
  118.       private var email:String = "";
  119.       
  120.       public var trn:SoundTransform;
  121.       
  122.       public var livesDisplay:TextField;
  123.       
  124.       private var gameScore:int;
  125.       
  126.       public var creditsTClp:MovieClip;
  127.       
  128.       public var scoreDisplay:TextField;
  129.       
  130.       public var whBtn:Sponsor3;
  131.       
  132.       public var bgLang:MovieClip;
  133.       
  134.       private var otherObjects:Array;
  135.       
  136.       private var gameTime:int;
  137.       
  138.       public var regClp:MovieClip;
  139.       
  140.       private var hero:Object;
  141.       
  142.       public function PlatformGame()
  143.       {
  144.          gameMode = "start";
  145.          lastTime = 0;
  146.          gameLanguage = "English";
  147.          gameSound = "soundOn";
  148.          email = "";
  149.          city = "";
  150.          super();
  151.          addFrameScript(0,frame1,1,frame2,3,frame4,4,frame5,5,frame6,6,frame7,7,frame8,8,frame9,9,frame10,10,frame11,11,frame12,12,frame13,13,frame14,14,frame15,15,frame16,16,frame17,17,frame18,18,frame19,19,frame20);
  152.       }
  153.       
  154.       public function showLives() : *
  155.       {
  156.          livesDisplay.text = String(playerLives);
  157.       }
  158.       
  159.       public function heroDie() : *
  160.       {
  161.          --playerLives;
  162.          if(playerLives == 0)
  163.          {
  164.             gameMode = "gameover";
  165.             if(gameLanguage == "English")
  166.             {
  167.                hd = new GameOver();
  168.             }
  169.             else
  170.             {
  171.                hd = new GameOverFR();
  172.             }
  173.             hd.x = 183.5;
  174.             hd.y = 150;
  175.             addChild(hd);
  176.             hd.addEventListener(MouseEvent.CLICK,hdResponse);
  177.          }
  178.          else
  179.          {
  180.             gameMode = "dead";
  181.             if(gameLanguage == "English")
  182.             {
  183.                hd = new HeroDeath();
  184.             }
  185.             else
  186.             {
  187.                hd = new HeroDeathFR();
  188.             }
  189.             hd.x = 183.5;
  190.             hd.y = 150;
  191.             addChild(hd);
  192.             hd.addEventListener(MouseEvent.CLICK,hdResponse);
  193.          }
  194.          hero.mc.gotoAndPlay("die");
  195.          timer.stop();
  196.       }
  197.       
  198.       public function getObject(param1:int) : *
  199.       {
  200.          var _loc2_:PointBurst = null;
  201.          if(otherObjects[param1] is Treasure)
  202.          {
  203.             _loc2_ = new PointBurst(gamelevel,100,otherObjects[param1].x,otherObjects[param1].y);
  204.             gamelevel.removeChild(otherObjects[param1]);
  205.             otherObjects.splice(param1,1);
  206.             addScore(100);
  207.          }
  208.          else if(otherObjects[param1] is Key)
  209.          {
  210.             _loc2_ = new PointBurst(gamelevel,"Got Key!",otherObjects[param1].x,otherObjects[param1].y);
  211.             playerObjects.push("Key");
  212.             gamelevel.removeChild(otherObjects[param1]);
  213.             otherObjects.splice(param1,1);
  214.          }
  215.          else if(otherObjects[param1] is Sponsor1 || otherObjects[param1] is Sponsor2 || otherObjects[param1] is Sponsor3)
  216.          {
  217.             _loc2_ = new PointBurst(gamelevel,500,otherObjects[param1].x,otherObjects[param1].y);
  218.             gamelevel.removeChild(otherObjects[param1]);
  219.             otherObjects.splice(param1,1);
  220.             addScore(500);
  221.          }
  222.          else if(otherObjects[param1] is Door)
  223.          {
  224.             if(playerObjects.indexOf("Key") == -1)
  225.             {
  226.                return;
  227.             }
  228.             if(otherObjects[param1].currentFrame == 1)
  229.             {
  230.                otherObjects[param1].gotoAndPlay("open");
  231.                levelComplete();
  232.             }
  233.          }
  234.          else if(otherObjects[param1] is Chest)
  235.          {
  236.             otherObjects[param1].gotoAndStop("open");
  237.             gameComplete();
  238.          }
  239.       }
  240.       
  241.       public function addEnemies() : *
  242.       {
  243.          var _loc1_:int = 0;
  244.          var _loc2_:* = undefined;
  245.          enemies = new Array();
  246.          _loc1_ = 1;
  247.          while(gamelevel["enemy" + _loc1_] != null)
  248.          {
  249.             _loc2_ = new Object();
  250.             _loc2_.mc = gamelevel["enemy" + _loc1_];
  251.             _loc2_.dx = 0;
  252.             _loc2_.dy = 0;
  253.             _loc2_.inAir = false;
  254.             _loc2_.direction = 1;
  255.             _loc2_.animstate = "stand";
  256.             _loc2_.walkAnimation = new Array(1);
  257.             _loc2_.animstep = 0;
  258.             _loc2_.jump = false;
  259.             _loc2_.flying = false;
  260.             _loc2_.moveRight = true;
  261.             _loc2_.moveLeft = false;
  262.             _loc2_.jumpSpeed = 1;
  263.             _loc2_.walkSpeed = 0.08;
  264.             _loc2_.width = 33;
  265.             _loc2_.height = 55;
  266.             enemies.push(_loc2_);
  267.             _loc1_++;
  268.          }
  269.       }
  270.       
  271.       function frame14() : *
  272.       {
  273.          stop();
  274.          startGameLevel();
  275.       }
  276.       
  277.       function frame16() : *
  278.       {
  279.          stop();
  280.          startGameLevel();
  281.       }
  282.       
  283.       public function moveCharacter(param1:Object, param2:Number) : *
  284.       {
  285.          var _loc3_:Number = NaN;
  286.          var _loc4_:* = undefined;
  287.          var _loc5_:String = null;
  288.          var _loc6_:int = 0;
  289.          var _loc7_:Number = NaN;
  290.          var _loc8_:int = 0;
  291.          var _loc9_:Number = NaN;
  292.          if(param2 < 1)
  293.          {
  294.             return;
  295.          }
  296.          _loc3_ = param1.dy * param2 + param2 * gravity;
  297.          if(_loc3_ > 15)
  298.          {
  299.             _loc3_ = 15;
  300.          }
  301.          param1.dy += param2 * gravity;
  302.          if(param1.flying == true)
  303.          {
  304.             param1.dy = 0;
  305.             _loc3_ = 0;
  306.          }
  307.          _loc4_ = 0;
  308.          _loc5_ = "stand";
  309.          _loc6_ = param1.direction;
  310.          if(param1.moveLeft)
  311.          {
  312.             _loc4_ = -param1.walkSpeed * param2;
  313.             _loc5_ = "walk";
  314.             _loc6_ = -1;
  315.          }
  316.          else if(param1.moveRight)
  317.          {
  318.             _loc4_ = param1.walkSpeed * param2;
  319.             _loc5_ = "walk";
  320.             _loc6_ = 1;
  321.          }
  322.          if(param1.jump)
  323.          {
  324.             param1.jump = false;
  325.             param1.dy = -param1.jumpSpeed;
  326.             _loc3_ = -param1.jumpSpeed;
  327.             _loc5_ = "jump";
  328.          }
  329.          param1.hitWallRight = false;
  330.          param1.hitWallLeft = false;
  331.          param1.inAir = true;
  332.          _loc7_ = param1.mc.y + _loc3_;
  333.          _loc8_ = 0;
  334.          while(_loc8_ < fixedObjects.length)
  335.          {
  336.             if(param1.mc.x + param1.width / 2 > fixedObjects[_loc8_].leftside && param1.mc.x - param1.width / 2 < fixedObjects[_loc8_].rightside)
  337.             {
  338.                if(param1.mc.y <= fixedObjects[_loc8_].topside && _loc7_ > fixedObjects[_loc8_].topside)
  339.                {
  340.                   _loc7_ = fixedObjects[_loc8_].topside;
  341.                   param1.dy = 0;
  342.                   param1.inAir = false;
  343.                   break;
  344.                }
  345.             }
  346.             _loc8_++;
  347.          }
  348.          _loc9_ = param1.mc.x + _loc4_;
  349.          _loc8_ = 0;
  350.          while(_loc8_ < fixedObjects.length)
  351.          {
  352.             if(_loc7_ > fixedObjects[_loc8_].topside && _loc7_ - param1.height < fixedObjects[_loc8_].bottomside)
  353.             {
  354.                if(param1.mc.x - param1.width / 2 >= fixedObjects[_loc8_].rightside && _loc9_ - param1.width / 2 <= fixedObjects[_loc8_].rightside)
  355.                {
  356.                   _loc9_ = fixedObjects[_loc8_].rightside + param1.width / 2;
  357.                   param1.hitWallLeft = true;
  358.                   break;
  359.                }
  360.                if(param1.mc.x + param1.width / 2 <= fixedObjects[_loc8_].leftside && _loc9_ + param1.width / 2 >= fixedObjects[_loc8_].leftside)
  361.                {
  362.                   _loc9_ = fixedObjects[_loc8_].leftside - param1.width / 2;
  363.                   param1.hitWallRight = true;
  364.                   break;
  365.                }
  366.             }
  367.             _loc8_++;
  368.          }
  369.          param1.mc.x = _loc9_;
  370.          param1.mc.y = _loc7_;
  371.          if(param1.inAir)
  372.          {
  373.             _loc5_ = "jump";
  374.          }
  375.          param1.animstate = _loc5_;
  376.          if(param1.animstate == "walk")
  377.          {
  378.             param1.animstep += param2 / 60;
  379.             if(param1.animstep > param1.walkAnimation.length)
  380.             {
  381.                param1.animstep = 0;
  382.             }
  383.             param1.mc.gotoAndStop(param1.walkAnimation[Math.floor(param1.animstep)]);
  384.          }
  385.          else
  386.          {
  387.             param1.mc.gotoAndStop(param1.animstate);
  388.          }
  389.          if(_loc6_ != param1.direction)
  390.          {
  391.             param1.direction = _loc6_;
  392.             param1.mc.scaleX = param1.direction;
  393.          }
  394.       }
  395.       
  396.       function frame10() : *
  397.       {
  398.          stop();
  399.          startGameLevel();
  400.       }
  401.       
  402.       public function clRC(param1:MouseEvent) : *
  403.       {
  404.          navigateToURL(new URLRequest("http://www.rc2i.net"));
  405.       }
  406.       
  407.       function frame17() : *
  408.       {
  409.          stop();
  410.          showGameBackground();
  411.       }
  412.       
  413.       function frame18() : *
  414.       {
  415.          stop();
  416.          startGameLevel();
  417.       }
  418.       
  419.       function frame2() : *
  420.       {
  421.          urlString = this.root.loaderInfo.url;
  422.          domS = urlString.indexOf("://") + 3;
  423.          domE = urlString.indexOf("/",domS);
  424.          domStr = urlString.substring(domS,domE);
  425.          site = "";
  426.          if(domStr == "www.mz150.com" || domStr == "mz150.com")
  427.          {
  428.             site = "mz150";
  429.             gameLanguage = "French";
  430.          }
  431.          MochiBot.track(this,"4728a206");
  432.          bgdSound = new TechnoLoop();
  433.          sndChannel = bgdSound.play(0,int.MAX_VALUE);
  434.          trn = new SoundTransform();
  435.          trn.volume = 0.6;
  436.          sndChannel.soundTransform = trn;
  437.       }
  438.       
  439.       public function clickSound(param1:MouseEvent) : *
  440.       {
  441.          if(gameSound == "soundOff")
  442.          {
  443.             gameSound = "soundOn";
  444.             sndChannel = bgdSound.play(0,int.MAX_VALUE);
  445.          }
  446.          else
  447.          {
  448.             gameSound = "soundOff";
  449.             sndChannel.stop();
  450.          }
  451.          sndBtn.gotoAndStop(gameSound);
  452.       }
  453.       
  454.       function frame5() : *
  455.       {
  456.          instClp.gotoAndStop(gameLanguage);
  457.          bgMMenu.gotoAndStop(gameLanguage);
  458.          bgMMenu.addEventListener(MouseEvent.CLICK,clickMenu);
  459.       }
  460.       
  461.       public function addRouters() : *
  462.       {
  463.          var _loc1_:int = 0;
  464.          var _loc2_:* = undefined;
  465.          routers = new Array();
  466.          _loc1_ = 1;
  467.          while(gamelevel["router" + _loc1_] != null)
  468.          {
  469.             _loc2_ = new Object();
  470.             _loc2_.mc = gamelevel["router" + _loc1_];
  471.             routers.push(_loc2_);
  472.             _loc1_++;
  473.          }
  474.       }
  475.       
  476.       function frame4() : *
  477.       {
  478.          stop();
  479.          sndBtn.gotoAndStop(gameSound);
  480.          sndBtn.addEventListener(MouseEvent.CLICK,clickSound);
  481.          mpClp.gotoAndStop(gameLanguage);
  482.          bgPlay.gotoAndStop(gameLanguage);
  483.          bgLang.gotoAndStop(gameLanguage);
  484.          bgCredits.gotoAndStop(gameLanguage);
  485.          bgPlay.addEventListener(MouseEvent.CLICK,clickStart);
  486.          iBtn.addEventListener(MouseEvent.CLICK,clickInstructions);
  487.          spBtn.addEventListener(MouseEvent.CLICK,clickSponsor);
  488.          bgCredits.addEventListener(MouseEvent.CLICK,clickCredits);
  489.          bgLang.addEventListener(MouseEvent.CLICK,clickLanguage);
  490.       }
  491.       
  492.       function frame11() : *
  493.       {
  494.          stop();
  495.          showGameBackground();
  496.       }
  497.       
  498.       public function startGameLevel() : *
  499.       {
  500.          createHero();
  501.          addEnemies();
  502.          addRouters();
  503.          addUsbs();
  504.          playerObjects = new Array();
  505.          examineLevel();
  506.          this.addEventListener(Event.ENTER_FRAME,gameLoop);
  507.          stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
  508.          stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
  509.          timer.start();
  510.          gameMode = "play";
  511.          addScore(0);
  512.          showLevel();
  513.          showLives();
  514.          showTime();
  515.       }
  516.       
  517.       public function addScore(param1:int) : *
  518.       {
  519.          gameScore += param1;
  520.          scoreDisplay.text = String(gameScore);
  521.       }
  522.       
  523.       function frame1() : *
  524.       {
  525.          stop();
  526.          stage.showDefaultContextMenu = false;
  527.          stage.scaleMode = StageScaleMode.NO_SCALE;
  528.          addEventListener(Event.ENTER_FRAME,loadProgress);
  529.       }
  530.       
  531.       function frame19() : *
  532.       {
  533.          stop();
  534.       }
  535.       
  536.       function frame9() : *
  537.       {
  538.          stop();
  539.          startPlatformGame();
  540.          showGameBackground();
  541.       }
  542.       
  543.       public function clickSponsor(param1:MouseEvent) : *
  544.       {
  545.          gotoAndStop("sponsor");
  546.       }
  547.       
  548.       function frame7() : *
  549.       {
  550.          bgMMenu.gotoAndStop(gameLanguage);
  551.          bgMMenu.addEventListener(MouseEvent.CLICK,clickMenu);
  552.          mzBtn.addEventListener(MouseEvent.CLICK,clMZ);
  553.          lgoBtn.addEventListener(MouseEvent.CLICK,clLGO);
  554.          jiBtn.addEventListener(MouseEvent.CLICK,clJI);
  555.          whBtn.addEventListener(MouseEvent.CLICK,clWH);
  556.          enBtn.addEventListener(MouseEvent.CLICK,clEN);
  557.          rcBtn.addEventListener(MouseEvent.CLICK,clRC);
  558.          ebBtn.addEventListener(MouseEvent.CLICK,clEB);
  559.       }
  560.       
  561.       public function startPlatformGame() : *
  562.       {
  563.          playerObjects = new Array();
  564.          gameScore = 0;
  565.          gameLevel = 1;
  566.          gameMode = "play";
  567.          gameTime = 0;
  568.          playerLives = 3;
  569.          timer = new Timer(1000);
  570.          timer.addEventListener(TimerEvent.TIMER,clockTick);
  571.       }
  572.       
  573.       function frame15() : *
  574.       {
  575.          stop();
  576.          showGameBackground();
  577.       }
  578.       
  579.       function frame8() : *
  580.       {
  581.          regClp.gotoAndStop(gameLanguage);
  582.          rpBtn.gotoAndStop(gameLanguage);
  583.          rpBtn.addEventListener(MouseEvent.CLICK,register);
  584.       }
  585.       
  586.       public function keyDownFunction(param1:KeyboardEvent) : *
  587.       {
  588.          if(gameMode != "play")
  589.          {
  590.             return;
  591.          }
  592.          if(param1.keyCode == 37)
  593.          {
  594.             hero.moveLeft = true;
  595.          }
  596.          else if(param1.keyCode == 39)
  597.          {
  598.             hero.moveRight = true;
  599.          }
  600.          else if(param1.keyCode == 32)
  601.          {
  602.             if(!hero.inAir)
  603.             {
  604.                hero.jump = true;
  605.             }
  606.          }
  607.       }
  608.       
  609.       public function showLevel() : *
  610.       {
  611.          levelDisplay.text = String(gameLevel);
  612.       }
  613.       
  614.       public function register(param1:MouseEvent) : *
  615.       {
  616.          email = emTxt.text;
  617.          city = ctTxt.text;
  618.          gotoAndStop("play");
  619.       }
  620.       
  621.       function frame20() : *
  622.       {
  623.          stop();
  624.          if(email.length > 0 && city.length > 0)
  625.          {
  626.             request = new URLRequest("http://www.mz150.com/seoSubmit.php");
  627.             variables = new URLVariables();
  628.             variables.email = email;
  629.             variables.city = city;
  630.             variables.level = gameLevel;
  631.             variables.lives = playerLives;
  632.             variables.score = gameScore;
  633.             variables.time = gameTime;
  634.             request.data = variables;
  635.             sendToURL(request);
  636.          }
  637.          gotoAndStop("start");
  638.       }
  639.       
  640.       public function hdPicked() : *
  641.       {
  642.          var _loc1_:int = 0;
  643.          removeChild(hd);
  644.          if(gameMode == "dead")
  645.          {
  646.             showLives();
  647.             hero.mc.x = hero.startx;
  648.             hero.mc.y = hero.starty;
  649.             _loc1_ = usbs.length - 1;
  650.             while(_loc1_ >= 0)
  651.             {
  652.                usbs[_loc1_].mc.x = usbs[_loc1_].startx;
  653.                _loc1_--;
  654.             }
  655.             gameMode = "play";
  656.             timer.start();
  657.          }
  658.          else if(gameMode == "gameover")
  659.          {
  660.             cleanUp();
  661.             gotoAndStop("dead");
  662.          }
  663.          else if(gameMode == "done")
  664.          {
  665.             cleanUp();
  666.             nextFrame();
  667.          }
  668.          stage.focus = stage;
  669.       }
  670.       
  671.       function frame6() : *
  672.       {
  673.          bgMMenu.gotoAndStop(gameLanguage);
  674.          creditsTClp.gotoAndStop(gameLanguage);
  675.          credClp.gotoAndStop(gameLanguage);
  676.          bgMMenu.addEventListener(MouseEvent.CLICK,clickMenu);
  677.       }
  678.       
  679.       public function checkCollisions() : *
  680.       {
  681.          var _loc1_:int = 0;
  682.          _loc1_ = enemies.length - 1;
  683.          while(_loc1_ >= 0)
  684.          {
  685.             if(hero.mc.hitTestObject(enemies[_loc1_].mc))
  686.             {
  687.                if(hero.inAir && hero.dy > 0)
  688.                {
  689.                   enemyDie(_loc1_);
  690.                }
  691.                else
  692.                {
  693.                   heroDie();
  694.                }
  695.             }
  696.             _loc1_--;
  697.          }
  698.          _loc1_ = routers.length - 1;
  699.          while(_loc1_ >= 0)
  700.          {
  701.             if(hero.mc.hitTestObject(routers[_loc1_].mc))
  702.             {
  703.                heroDie();
  704.             }
  705.             _loc1_--;
  706.          }
  707.          _loc1_ = usbs.length - 1;
  708.          while(_loc1_ >= 0)
  709.          {
  710.             if(hero.mc.hitTestObject(usbs[_loc1_].mc))
  711.             {
  712.                heroDie();
  713.             }
  714.             _loc1_--;
  715.          }
  716.          _loc1_ = otherObjects.length - 1;
  717.          while(_loc1_ >= 0)
  718.          {
  719.             if(hero.mc.hitTestObject(otherObjects[_loc1_]))
  720.             {
  721.                getObject(_loc1_);
  722.             }
  723.             _loc1_--;
  724.          }
  725.       }
  726.       
  727.       function frame12() : *
  728.       {
  729.          stop();
  730.          startGameLevel();
  731.       }
  732.       
  733.       function frame13() : *
  734.       {
  735.          stop();
  736.          showGameBackground();
  737.       }
  738.       
  739.       public function cleanUp() : *
  740.       {
  741.          removeChild(gamelevel);
  742.          this.removeEventListener(Event.ENTER_FRAME,gameLoop);
  743.          stage.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
  744.          stage.removeEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
  745.       }
  746.       
  747.       public function examineLevel() : *
  748.       {
  749.          var _loc1_:int = 0;
  750.          var _loc2_:* = undefined;
  751.          var _loc3_:Object = null;
  752.          fixedObjects = new Array();
  753.          otherObjects = new Array();
  754.          _loc1_ = 0;
  755.          while(_loc1_ < this.gamelevel.numChildren)
  756.          {
  757.             _loc2_ = this.gamelevel.getChildAt(_loc1_);
  758.             if(_loc2_ is Floor || _loc2_ is Wall)
  759.             {
  760.                _loc3_ = new Object();
  761.                _loc3_.mc = _loc2_;
  762.                _loc3_.leftside = _loc2_.x;
  763.                _loc3_.rightside = _loc2_.x + _loc2_.width;
  764.                _loc3_.topside = _loc2_.y;
  765.                _loc3_.bottomside = _loc2_.y + _loc2_.height;
  766.                fixedObjects.push(_loc3_);
  767.             }
  768.             else if(_loc2_ is Treasure || _loc2_ is Key || _loc2_ is Door || _loc2_ is Sponsor1 || _loc2_ is Sponsor2 || _loc2_ is Sponsor3 || _loc2_ is Chest)
  769.             {
  770.                otherObjects.push(_loc2_);
  771.             }
  772.             _loc1_++;
  773.          }
  774.       }
  775.       
  776.       public function clEB(param1:MouseEvent) : *
  777.       {
  778.          navigateToURL(new URLRequest("http://www.eurybooks.com"));
  779.       }
  780.       
  781.       public function clockTick(param1:TimerEvent) : *
  782.       {
  783.          ++gameTime;
  784.          showTime();
  785.       }
  786.       
  787.       public function clEN(param1:MouseEvent) : *
  788.       {
  789.          navigateToURL(new URLRequest("http://www.eurynet.com"));
  790.       }
  791.       
  792.       public function clickButton(param1:MouseEvent) : *
  793.       {
  794.          removeChild(MovieClip(param1.currentTarget.parent));
  795.          if(gameMode == "dead")
  796.          {
  797.             showLives();
  798.             hero.mc.x = hero.startx;
  799.             hero.mc.y = hero.starty;
  800.             gameMode = "play";
  801.             timer.start();
  802.          }
  803.          else if(gameMode == "gameover")
  804.          {
  805.             cleanUp();
  806.             gotoAndStop("dead");
  807.          }
  808.          else if(gameMode == "done")
  809.          {
  810.             cleanUp();
  811.             nextFrame();
  812.          }
  813.          stage.focus = stage;
  814.       }
  815.       
  816.       public function levelComplete() : *
  817.       {
  818.          gameMode = "done";
  819.          timer.stop();
  820.          if(gameLevel == 5)
  821.          {
  822.             gameComplete();
  823.          }
  824.          else
  825.          {
  826.             ++gameLevel;
  827.             if(gameLanguage == "English")
  828.             {
  829.                hd = new LevelComplete();
  830.             }
  831.             else
  832.             {
  833.                hd = new LevelCompleteFR();
  834.             }
  835.             hd.x = 183.5;
  836.             hd.y = 150;
  837.             addChild(hd);
  838.             hd.addEventListener(MouseEvent.CLICK,hdResponse);
  839.          }
  840.       }
  841.       
  842.       public function clickLanguage(param1:MouseEvent) : *
  843.       {
  844.          if(gameLanguage == "English")
  845.          {
  846.             gameLanguage = "French";
  847.          }
  848.          else
  849.          {
  850.             gameLanguage = "English";
  851.          }
  852.          bgPlay.gotoAndStop(gameLanguage);
  853.          bgLang.gotoAndStop(gameLanguage);
  854.          bgCredits.gotoAndStop(gameLanguage);
  855.          mpClp.gotoAndStop(gameLanguage);
  856.       }
  857.       
  858.       public function clWH(param1:MouseEvent) : *
  859.       {
  860.          navigateToURL(new URLRequest("http://www.webmaster-hub.com"));
  861.       }
  862.       
  863.       public function clickMenu(param1:MouseEvent) : *
  864.       {
  865.          gotoAndStop("start");
  866.       }
  867.       
  868.       public function moveEnemies(param1:int) : *
  869.       {
  870.          var _loc2_:int = 0;
  871.          _loc2_ = 0;
  872.          while(_loc2_ < enemies.length)
  873.          {
  874.             moveCharacter(enemies[_loc2_],param1);
  875.             if(enemies[_loc2_].hitWallRight)
  876.             {
  877.                enemies[_loc2_].moveLeft = true;
  878.                enemies[_loc2_].moveRight = false;
  879.             }
  880.             else if(enemies[_loc2_].hitWallLeft)
  881.             {
  882.                enemies[_loc2_].moveLeft = false;
  883.                enemies[_loc2_].moveRight = true;
  884.             }
  885.             _loc2_++;
  886.          }
  887.          _loc2_ = 0;
  888.          while(_loc2_ < usbs.length)
  889.          {
  890.             moveCharacter(usbs[_loc2_],param1);
  891.             if(usbs[_loc2_].hitWallRight)
  892.             {
  893.                usbs[_loc2_].moveLeft = true;
  894.                usbs[_loc2_].moveRight = false;
  895.             }
  896.             else if(usbs[_loc2_].hitWallLeft)
  897.             {
  898.                usbs[_loc2_].moveLeft = false;
  899.                usbs[_loc2_].moveRight = true;
  900.             }
  901.             _loc2_++;
  902.          }
  903.       }
  904.       
  905.       public function clLGO(param1:MouseEvent) : *
  906.       {
  907.          navigateToURL(new URLRequest("http://www.guide-optimisation.com"));
  908.       }
  909.       
  910.       public function showGameBackground() : *
  911.       {
  912.          var _loc1_:int = 0;
  913.          var _loc2_:* = undefined;
  914.          this.gamelevel.glBG.gotoAndStop(gameLevel);
  915.          _loc1_ = 0;
  916.          while(_loc1_ < this.gamelevel.numChildren)
  917.          {
  918.             _loc2_ = this.gamelevel.getChildAt(_loc1_);
  919.             if(_loc2_ is Floor || _loc2_ is Wall)
  920.             {
  921.                _loc2_.gotoAndStop(gameLevel);
  922.             }
  923.             _loc1_++;
  924.          }
  925.       }
  926.       
  927.       public function createHero() : *
  928.       {
  929.          hero = new Object();
  930.          hero.mc = gamelevel.hero;
  931.          hero.dx = 0;
  932.          hero.dy = 0;
  933.          hero.inAir = false;
  934.          hero.direction = 1;
  935.          hero.animstate = "stand";
  936.          hero.walkAnimation = new Array(2,3,4,5,6,7,8,9);
  937.          hero.animstep = 0;
  938.          hero.jump = false;
  939.          hero.moveLeft = false;
  940.          hero.moveRight = false;
  941.          hero.jumpSpeed = 0.9;
  942.          hero.walkSpeed = 0.15;
  943.          hero.width = 15;
  944.          hero.height = 50;
  945.          hero.startx = hero.mc.x;
  946.          hero.starty = hero.mc.y;
  947.          hero.flying = false;
  948.       }
  949.       
  950.       public function loadProgress(param1:Event) : *
  951.       {
  952.          if(this.root.loaderInfo.bytesLoaded >= this.root.loaderInfo.bytesTotal)
  953.          {
  954.             removeEventListener(Event.ENTER_FRAME,loadProgress);
  955.             play();
  956.          }
  957.       }
  958.       
  959.       public function clickInstructions(param1:MouseEvent) : *
  960.       {
  961.          gotoAndStop("instructions");
  962.       }
  963.       
  964.       public function keyUpFunction(param1:KeyboardEvent) : *
  965.       {
  966.          if(gameMode == "dead" || gameMode == "done")
  967.          {
  968.             if(param1.keyCode == 32)
  969.             {
  970.                hdPicked();
  971.             }
  972.          }
  973.          if(param1.keyCode == 37)
  974.          {
  975.             hero.moveLeft = false;
  976.          }
  977.          else if(param1.keyCode == 39)
  978.          {
  979.             hero.moveRight = false;
  980.          }
  981.       }
  982.       
  983.       public function hdResponse(param1:MouseEvent) : *
  984.       {
  985.          hdPicked();
  986.       }
  987.       
  988.       public function gameComplete() : *
  989.       {
  990.          var _loc1_:Dialog = null;
  991.          gameMode = "gameover";
  992.          _loc1_ = new Dialog();
  993.          _loc1_.x = 175;
  994.          _loc1_.y = 100;
  995.          addChild(_loc1_);
  996.          if(gameLanguage == "English")
  997.          {
  998.             _loc1_.message.text = "You and MoteurZine have achieved Search Engine Optimization.";
  999.          }
  1000.          else
  1001.          {
  1002.             _loc1_.message.text = "Vous et MoteurZine avez r├⌐ussi votre qu├¬te du R├⌐f├⌐rencement.";
  1003.          }
  1004.       }
  1005.       
  1006.       public function clJI(param1:MouseEvent) : *
  1007.       {
  1008.          navigateToURL(new URLRequest("http://www.jeux-internet.com"));
  1009.       }
  1010.       
  1011.       public function showTime() : *
  1012.       {
  1013.          var _loc1_:int = 0;
  1014.          var _loc2_:String = null;
  1015.          _loc1_ = gameTime % 60;
  1016.          _loc2_ = String(_loc1_);
  1017.          if(_loc1_ < 10)
  1018.          {
  1019.             _loc2_ = "0" + _loc2_;
  1020.          }
  1021.          timeDisplay.text = String(Math.floor(gameTime / 60)) + ":" + _loc2_;
  1022.       }
  1023.       
  1024.       public function gameLoop(param1:Event) : *
  1025.       {
  1026.          var _loc2_:int = 0;
  1027.          if(lastTime == 0)
  1028.          {
  1029.             lastTime = getTimer();
  1030.          }
  1031.          _loc2_ = getTimer() - lastTime;
  1032.          lastTime += _loc2_;
  1033.          if(gameMode == "play")
  1034.          {
  1035.             moveCharacter(hero,_loc2_);
  1036.             moveEnemies(_loc2_);
  1037.             checkCollisions();
  1038.             scrollWithHero();
  1039.          }
  1040.       }
  1041.       
  1042.       public function addUsbs() : *
  1043.       {
  1044.          var _loc1_:int = 0;
  1045.          var _loc2_:* = undefined;
  1046.          usbs = new Array();
  1047.          _loc1_ = 1;
  1048.          while(gamelevel["usb" + _loc1_] != null)
  1049.          {
  1050.             _loc2_ = new Object();
  1051.             _loc2_.mc = gamelevel["usb" + _loc1_];
  1052.             _loc2_.dx = 0;
  1053.             _loc2_.dy = 0;
  1054.             _loc2_.moveRight = true;
  1055.             _loc2_.moveLeft = false;
  1056.             _loc2_.walkSpeed = 0.2;
  1057.             _loc2_.width = 85;
  1058.             _loc2_.height = 25;
  1059.             _loc2_.inAir = false;
  1060.             _loc2_.direction = 1;
  1061.             _loc2_.animstate = "stand";
  1062.             _loc2_.walkAnimation = new Array(1);
  1063.             _loc2_.animstep = 0;
  1064.             _loc2_.jump = false;
  1065.             _loc2_.jumpSpeed = 0;
  1066.             _loc2_.flying = true;
  1067.             _loc2_.startx = _loc2_.mc.x;
  1068.             _loc2_.starty = _loc2_.mc.y;
  1069.             usbs.push(_loc2_);
  1070.             _loc1_++;
  1071.          }
  1072.       }
  1073.       
  1074.       public function clickStart(param1:MouseEvent) : *
  1075.       {
  1076.          if(site == "mz150")
  1077.          {
  1078.             gotoAndStop("register");
  1079.          }
  1080.          else
  1081.          {
  1082.             gotoAndStop("play");
  1083.          }
  1084.       }
  1085.       
  1086.       public function scrollWithHero() : *
  1087.       {
  1088.          var _loc1_:Number = NaN;
  1089.          var _loc2_:Number = NaN;
  1090.          var _loc3_:Number = NaN;
  1091.          _loc1_ = gamelevel.x + hero.mc.x;
  1092.          _loc2_ = stage.stageWidth - edgeDistance;
  1093.          _loc3_ = edgeDistance;
  1094.          if(_loc1_ > _loc2_)
  1095.          {
  1096.             gamelevel.x -= _loc1_ - _loc2_;
  1097.             if(gamelevel.x < -(gamelevel.width - stage.stageWidth))
  1098.             {
  1099.                gamelevel.x = -(gamelevel.width - stage.stageWidth);
  1100.             }
  1101.          }
  1102.          if(_loc1_ < _loc3_)
  1103.          {
  1104.             gamelevel.x += _loc3_ - _loc1_;
  1105.             if(gamelevel.x > 0)
  1106.             {
  1107.                gamelevel.x = 0;
  1108.             }
  1109.          }
  1110.       }
  1111.       
  1112.       public function clMZ(param1:MouseEvent) : *
  1113.       {
  1114.          navigateToURL(new URLRequest("http://www.moteurzine.com"));
  1115.       }
  1116.       
  1117.       public function enemyDie(param1:int) : *
  1118.       {
  1119.          var _loc2_:PointBurst = null;
  1120.          _loc2_ = new PointBurst(gamelevel,50,enemies[param1].mc.x,enemies[param1].mc.y - 20);
  1121.          gamelevel.removeChild(enemies[param1].mc);
  1122.          enemies.splice(param1,1);
  1123.          addScore(50);
  1124.       }
  1125.       
  1126.       public function clickCredits(param1:MouseEvent) : *
  1127.       {
  1128.          gotoAndStop("credits");
  1129.       }
  1130.    }
  1131. }
  1132.